### 
# @Description: etcd
 # @version: 1.0.0
 # @Company: sdbean
 # @Author: Symars
 # @Date: 2020-04-13 01:08:24
 # @LastEditors: Symars
 # @LastEditTime: 2020-04-13 01:08:24
 ###

#etcd-node1 
 docker run -it -d -p 2379:2379 -p 2380:2380 \
 -v /data/lib/etcd-data:/etcd-data \
 --name mg-etcd quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
 --name etcd-node1 --data-dir /etcd-data \
 --initial-advertise-peer-urls http://172.16.151.59:2380 \
 --listen-peer-urls http://0.0.0.0:2380 \
 --advertise-client-urls http://172.16.151.59:2379 \
 --listen-client-urls http://0.0.0.0:2379 \
 --initial-cluster-state new --initial-cluster-token mg-docker-etcd \
 --initial-cluster etcd-node1=http://172.16.151.59:2380,etcd-node2=http://172.16.151.60:2380,etcd-node3=http://172.16.151.61:2380 \
 --log-level info --logger zap --log-outputs stderr

#etcd-node2 
 docker run -it -d -p 2379:2379 -p 2380:2380 \
 -v /data/lib/etcd-data:/etcd-data \
 --name mg-etcd quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
 --name etcd-node2 --data-dir /etcd-data \
 --initial-advertise-peer-urls http://172.16.151.60:2380 \
 --listen-peer-urls http://0.0.0.0:2380 \
 --advertise-client-urls http://172.16.151.60:2379 \
 --listen-client-urls http://0.0.0.0:2379 \
 --initial-cluster-state new --initial-cluster-token mg-docker-etcd \
 --initial-cluster etcd-node1=http://172.16.151.59:2380,etcd-node2=http://172.16.151.60:2380,etcd-node3=http://172.16.151.61:2380 \
 --log-level info --logger zap --log-outputs stderr

 #etcd-node3
 docker run -it -d -p 2379:2379 -p 2380:2380 \
 -v /data/lib/etcd-data:/etcd-data \
 --name mg-etcd quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
 --name etcd-node3 --data-dir /etcd-data \
 --initial-advertise-peer-urls http://172.16.151.61:2380 \
 --listen-peer-urls http://0.0.0.0:2380 \
 --advertise-client-urls http://172.16.151.61:2379 \
 --listen-client-urls http://0.0.0.0:2379 \
 --initial-cluster-state new --initial-cluster-token mg-docker-etcd \
 --initial-cluster etcd-node1=http://172.16.151.59:2380,etcd-node2=http://172.16.151.60:2380,etcd-node3=http://172.16.151.61:2380 \
 --log-level info --logger zap --log-outputs stderr


docker exec mg-etcd /bin/sh -c "/usr/local/bin/etcd --version"
docker exec mg-etcd /bin/sh -c "/usr/local/bin/etcdctl version"
docker exec mg-etcd /bin/sh -c "/usr/local/bin/etcdctl endpoint health"
docker exec mg-etcd /bin/sh -c "/usr/local/bin/etcdctl put foo bar"
docker exec mg-etcd /bin/sh -c "/usr/local/bin/etcdctl get foo"


docker run --rm --name etcd-browser -p 8000:8000 --env ETCD_HOST=172.16.151.59 --env ETCD_PORT=2379 -t -i etcd-browser

docker run -it -d -p 8090:8090 -v /etc/config.default.ini:/app/conf/config.default.ini --name etcd-e3w  --env CLIENT_ADDR=172.16.151.59:2379,172.16.151.60:2379,172.16.151.61:2379 soyking/e3w:latest